let uu = document.querySelector('#list')
let id = getQueryString('brandtitleid')
let title=getQueryString('title')
$('.last-a').text(title)
console.log(id)
let el = ""
function getData(pageid = 1) {
fetch('http://chst.vip:1234/api/getbrandproductlist?brandtitleid=' + id)
    .then(body => body.json())
    .then(res => {
        console.log(res)
        // let el = ""
        res.result.forEach(item => {
            el += `<div categoryid=${item.categoryId} class="product" productid=${item.productId} brandname=${item.brandName}>
        <div class="img" categoryid=${item.categoryId} productid=${item.productId} brandname=${item.brandName}>${item.productImg}</div>
        <div class="content" productid=${item.productId} categoryid=${item.categoryId} brandname=${item.brandName}>
            <h4 categoryid=${item.categoryId} brandname=${item.brandName}>${item.productName}</h4>
            <b categoryid=${item.categoryId} brandname=${item.brandName}>${item.productPrice}</b>
            <span categoryid=${item.categoryId} brandname=${item.brandName}>${item.productQuote}</span>
            <i categoryid=${item.categoryId} brandname=${item.brandName}>${item.productCom}</i> </div> 
            </div>`
        });
        uu.innerHTML = el;
    }) 
}

    uu.onclick = function (e) {
        if(e.target.localName=='div') {
            let _this = e.target
            let id = _this.getAttribute('productid')
            let id1=_this.getAttribute('categoryid')
            let brandname=_this.getAttribute('brandname')
            console.log(brandname);
            location.href = './../pages/productlist.html?productid=' + id+'&categoryid='+id1+'&brandname='+brandname;
        }
    }
  
    getData()

    let pageid = 1;
    lazyLoad(function () {
        pageid++;
        if (pageid > 14) {
            alert('服务器没有更多的数据了！');
            return
        }
        getData(pageid)
    }, 100)